package com.sjtu.vfact.textual.tablemodel;

import com.sjtu.vfact.textual.model.MasterCollection;
import com.sjtu.vfact.textual.model.MasterTermset;
import com.sjtu.vfact.textual.model.TermSet;

public class MasterCollectionTableModel extends VFactTableModel{

	private static final long serialVersionUID = 4970183592591196720L;

	public static final int COL_TERMSET = 0;
	public static final int COL_SUPPORT = 1;
	public static final int COL_DOCPAIRS = 2;
	
//	public static final int COL_NO_WIDTH = 40;
	public static final int COL_TERMSET_WIDTH = 400;
	public static final int COL_SUPPORT_WIDTH = 50;
	public static final int COL_DOCPAIRS_WIDTH = 500;
	
	public MasterCollectionTableModel(){
		super();
		setColumnNames(new String[]{"Master Termset", "Support", "Document Pairs"});
	}
	
	public void initializeTableModel(MasterCollection collection){
		clearTable();
		Object[] tuple = null;
		
		for(MasterTermset mts : collection.getMasterTermsetList()){
			tuple = new Object[getColumnCount()];
			tuple[COL_TERMSET] = mts.getTermset();
			tuple[COL_SUPPORT] = mts.getSupport();
			tuple[COL_DOCPAIRS] = mts.getDocIds();
			addRow(tuple);
		}
				
	}
	
	@Override
	public Class<?> getColumnClass(int columnIndex) {
		if(columnIndex == COL_TERMSET){
			return TermSet.class;
		}else if(columnIndex == COL_SUPPORT){
			return Integer.class;
		}else if(columnIndex == COL_DOCPAIRS){
			return super.getColumnClass(columnIndex);
		}else{
			return null;
		}
		
	}
	
}
